package entity;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Record implements Comparable<Record> {
    private String dateTime;
    private int step;
    private long useTime;

    /**
     * 排序规则：时间由近到远
     */
    @Override
    public int compareTo(Record o) {
        DateTime d1 = DateUtil.parse(this.dateTime);
        DateTime d2 = DateUtil.parse(o.dateTime);
        return d2.compareTo(d1);
    }
}
